function validate(frm){	
	
	var error_count = 0;
	var regularExpression = /^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/;
	
	if(frm.email.value == '' || frm.password.value == '' || frm.confirmpassword.value == ''){
		document.getElementById('error_msg').innerHTML='请填写所有栏位';
		error_count++;
	}else{
		document.getElementById('error_msg').innerHTML='&nbsp;';
	}
	
	if(frm.email.value != ''){
		var x = frm.email.value;
		var atpos = x.indexOf("@");
		var dotpos = x.lastIndexOf(".");
		
		if (atpos<1 || dotpos<atpos+2 || dotpos+2 >= x.length){
			document.getElementById('email_msg').innerHTML = '* 邮箱地址格式不正确';	
			error_count++;
		} else {
			document.getElementById('email_msg').innerHTML = '&nbsp;';
		}
	}
	
	if(frm.password.value != ''){
		if(frm.password.value.length > 12 || frm.password.value.length < 6  ){
			document.getElementById('password_msg').innerHTML='* 新密码长度不正确';
			error_count++;
		}else{
			if (!frm.password.value.match(regularExpression)) {
				document.getElementById('password_msg').innerHTML='* 新密码格式不正确';
				error_count++;
			}else{
				document.getElementById('password_msg').innerHTML='&nbsp;';
			}				
		}
	}
	
	if(frm.confirmpassword.value != ''){
		if(frm.confirmpassword.value.length > 12 || frm.confirmpassword.value.length < 6  ){
			document.getElementById('confirmpassword_msg').innerHTML='* 确认密码长度不正确';
			error_count++;
		}else{
			if (!frm.confirmpassword.value.match(regularExpression)) {
				document.getElementById('confirmpassword_msg').innerHTML='* 确认密码格式不正确';
				error_count++;
			}else{
				if(frm.password.value != frm.confirmpassword.value){
					document.getElementById('confirmpassword_msg').innerHTML='* 两次输入密码不相符';
					error_count++;	
				}else{
					document.getElementById('confirmpassword_msg').innerHTML='&nbsp;';
				}
			}
		}
	}
		
	if(error_count > 0){ return false; }
	return true;
}